var app = getApp(),
appData = getApp().globalData,
utils = require('../../../../utils/utils.js');
Page({
  data: {
    today: 0,
  },
  exchange: function () {
    if (appData.share.total == 0) app.toast('赏金太少，无法抵现');
    else wx.navigateTo({ url: '../../exchange/exchange' });
  },
  onShow: function () {
    this.setData({ share: appData.share });
    // if (!this.data.share.length) return 0;
    console.log(appData.receive);
    var r = appData.receive, td = { tot: 0, num: 0 }, list = [];
    if (r) {
      for (let i = 0; i < r.length; i++) {
        if (utils.formatDate(new Date().getTime()) == r[i].date.split(' ')[0]) {
          td.num++;
          td.tot += parseInt(r[i].total);
        }
      }
      for (let i = 0; i < appData.receive.length; i++) {
        if (appData.receive[i].ex_date != null)
          list.push({
            id: i,
            img: appData.receive[i].avatar,
            name: appData.receive[i].nick,
            total: appData.receive[i].total,
            date: appData.receive[i].ex_date.split(' ')[0],
          })
      }
    }
    this.setData({ td: td, info: list })

  }, 
  
  onPullDownRefresh: function () {

  },

  onShareAppMessage: function () {

  }
})